<template>
	<view class="community">
		<view class="head_bg" style="height:100rpx;"></view>
		<view class="big_box" style="padding-top: 20rpx;">
			<view class="equ_list" v-for="(info,index) in list" :key="index">
				<view class="sell_title">
					<view class="sell_title_left">
						<view class="sell_name">{{info.residential_quarters_name}}</view>
						<view class="sell_address">{{info.residential_quarters_address}}</view>
					</view>
					<view class="sell_title_right">
						<view class="sell_money">结算：{{info.settlement_amount}}元</view>
						<view class="sell_address">{{info.settlement_time}}</view>
					</view>
				</view>
				<view class="equ_list_inner2">
					<view class="equ_list_inner_text2">订单:{{info.order_num}}单 </view>
					<view class="equ_list_inner_text3">帐号:{{info.agent_phone_number}}</view>
					<view class="equ_list_inner_text2">收入:{{info.order_income}}元</view>
					<view class="equ_list_inner_text3">分成模式:{{info.sharing_model}}</view>
					<view class="equ_list_inner_text2">套餐:{{info.set_meal_income}}元</view>
					<view class="equ_list_inner_text3">分成比例:{{info.sharing_ratio}}% </view>
					<view class="equ_list_inner_text2">电量:{{info.power_consumption}}度</view>
					<view class="equ_list_inner_text3">电费：{{info.order_electricity_fees}}元</view>
				</view>
			</view>
			<view v-if="list.length==0" class="margin-top-lg text-center">
				<image src='../../common/img/no_data.png' style="width:275rpx;height:312rpx;"></image>
			</view>
		</view>
		<view v-if="list.length>0" class="text-black text-df text-center bg-white padding-sm padding-left-lg be-gray">
			{{loadingTxt}} 共({{list.length}}条记录)
		</view>
	</view>
</template>

<script>
	let page=1,timer=null
	export default {
		data() {
			return {
				list:[],
				total:0,
				loadingTxt:'加载更多',
			}
		},
		onShow() {
			page=1;
			this.getInfo();
		},
		methods: {
			getInfo(){
				let that=this;
				that.http.tokenreq({
					url: 'settlement/v1/page',
					data: {"pageindex":page}
				}).then((res) => {
					let e=res.data;
					console.log(e);
					if(e.code==0 && e.success){
						this.list = e.rows;
						this.totle= e.total;
						page++
					}
				})
			},
			getmorelist(){
				this.loadingTxt='加载中'
				let that=this;
				that.http.tokenreq({
					url: 'settlement/v1/page',
					data: {"pageindex":page}
				}).then((res) => {
					console.log("res="+JSON.stringify(res));
					let e=res.data;
					if(e.code==0 && e.success){
						if(e.rows.length==0){
							that.loadingTxt="已经加载全部";
							return;
						}
						that.list=that.list.concat(e.rows);
						page++;
					}
				})
			},
			onReachBottom() {
				//阻止重复加载
				if(timer !== null){
					clearTimeout(timer)
				}
				timer=setTimeout(()=>this.getmorelist(),500)
			},
		}
	}
</script>
